package org.steven.crm.app.api.processor;

import org.steven.crm.app.api.AppKeys;
import org.steven.crm.app.api.processor.base.BaseProcessor;
import org.steven.crm.core.cache.RedisCache;
import org.steven.crm.core.utils.RandomCodeGenerator;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @Author wuzw
 * @Date 2023/6/24 12:32
 * @Version 1.0
 */
public class RandomCodeProcessor extends BaseProcessor {
    public void getCodeAction() throws Exception {
        String requestId = UUID.randomUUID().toString();
        String randomCode = RandomCodeGenerator.generateCodeString(4);
        RedisCache.setRandomCode(requestId, randomCode);
        String imageUrl = AppKeys.DOMAIN_API + "/randomCodeImage?requestId=" + requestId;

        Map<String, String> data = new HashMap<>();
        data.put("requestId", requestId);
        data.put("imageUrl", imageUrl);
        setObjectData(data);
    }

}
